package hu.elte.tudaskezelo.dbpedialike.activity;

import hu.elte.tudaskezelo.dbpedialike.R;

import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;
import android.widget.Toast;
import roboguice.activity.RoboActivity;
import roboguice.inject.InjectView;

public class ImageViewActivity extends RoboActivity{
	final String tag = "ImageViewActivity";
	public String photo;
	
	@InjectView(R.id.bigCityView)
	ImageView cityView;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.img);
		Log.d(tag, "OnCreate");
		
		showGraphics();
	}
	
	public void showGraphics(){
		
		photo = getIntent().getStringExtra("photo");
	
		Log.d(tag, "photo: " + photo);			

		try {
				Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(photo).getContent());
				cityView.setImageBitmap(bitmap);
			} catch (MalformedURLException e) {
				Log.e("Exception", "MalformedURLException");
			} catch (IOException e) {
				Log.e("Exception", "IOException");
			}
		}

}

